package fanglimao.hyear2.registry;

import fanglimao.hyear2.HiddenYears2;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.MapColor;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;

public class ModBlocks {
    public static final Block FUEL_METAL_ORE = new Block(FabricBlockSettings.create().strength(4.0f).requiresTool().mapColor(MapColor.STONE_GRAY).sounds(BlockSoundGroup.STONE));
    public static final Block DEEPSLATE_FUEL_METAL_ORE = new Block(FabricBlockSettings.create().strength(4.0f).requiresTool().mapColor(MapColor.DEEPSLATE_GRAY).sounds(BlockSoundGroup.DEEPSLATE));
    public static final Block AMETHYST_ESSENCE_ORE = new Block(FabricBlockSettings.create().strength(4.0f).requiresTool().mapColor(MapColor.STONE_GRAY).sounds(BlockSoundGroup.STONE));
    public static final Block DEEPSLATE_AMETHYST_ESSENCE_ORE = new Block(FabricBlockSettings.create().strength(4.0f).requiresTool().mapColor(MapColor.DEEPSLATE_GRAY).sounds(BlockSoundGroup.DEEPSLATE));
    public static final Block TIN_ORE = new Block(FabricBlockSettings.create().strength(4.0f).requiresTool().mapColor(MapColor.STONE_GRAY).sounds(BlockSoundGroup.STONE));
    public static final Block DEEPSLATE_TIN_ORE = new Block(FabricBlockSettings.create().strength(4.0f).requiresTool().mapColor(MapColor.DEEPSLATE_GRAY).sounds(BlockSoundGroup.DEEPSLATE));
    public static final Block TIN_BLOCK = new Block(FabricBlockSettings.create().strength(4.0f).requiresTool().mapColor(MapColor.PURPLE).sounds(BlockSoundGroup.METAL));

    public static void register() {
        Registry.register(Registries.BLOCK, new Identifier(HiddenYears2.MOD_ID, "fuel_metal_ore"), FUEL_METAL_ORE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "fuel_metal_ore"), new BlockItem(FUEL_METAL_ORE, new FabricItemSettings()));
        Registry.register(Registries.BLOCK, new Identifier(HiddenYears2.MOD_ID, "deepslate_fuel_metal_ore"), DEEPSLATE_FUEL_METAL_ORE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "deepslate_fuel_metal_ore"), new BlockItem(DEEPSLATE_FUEL_METAL_ORE, new FabricItemSettings()));
        Registry.register(Registries.BLOCK, new Identifier(HiddenYears2.MOD_ID, "amethyst_essence_ore"), AMETHYST_ESSENCE_ORE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "amethyst_essence_ore"), new BlockItem(AMETHYST_ESSENCE_ORE, new FabricItemSettings()));
        Registry.register(Registries.BLOCK, new Identifier(HiddenYears2.MOD_ID, "deepslate_amethyst_essence_ore"), DEEPSLATE_AMETHYST_ESSENCE_ORE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "deepslate_amethyst_essence_ore"), new BlockItem(DEEPSLATE_AMETHYST_ESSENCE_ORE, new FabricItemSettings()));
        Registry.register(Registries.BLOCK, new Identifier(HiddenYears2.MOD_ID, "deepslate_tin_ore"), DEEPSLATE_TIN_ORE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "deepslate_tin_ore"), new BlockItem(DEEPSLATE_TIN_ORE, new FabricItemSettings()));
        Registry.register(Registries.BLOCK, new Identifier(HiddenYears2.MOD_ID, "tin_ore"), TIN_ORE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "tin_ore"), new BlockItem(TIN_ORE, new FabricItemSettings()));
        Registry.register(Registries.BLOCK, new Identifier(HiddenYears2.MOD_ID, "tin_block"), TIN_BLOCK);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "tin_block"), new BlockItem(TIN_BLOCK, new FabricItemSettings()));
        ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(content -> {
        	content.addAfter(Items.DEEPSLATE_DIAMOND_ORE,AMETHYST_ESSENCE_ORE);
        	content.addAfter(AMETHYST_ESSENCE_ORE,DEEPSLATE_AMETHYST_ESSENCE_ORE);
        	content.addAfter(DEEPSLATE_AMETHYST_ESSENCE_ORE,TIN_ORE);
        	content.addAfter(TIN_ORE,DEEPSLATE_TIN_ORE);
        	
        });
        ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(content -> {
        	content.add(TIN_BLOCK);  	
        });
    }
}